<?php
$q_bb_query = "SELECT * FROM t_bb_detail a
	LEFT JOIN t_bb b ON a.kd_bb = b.kd_bb LEFT JOIN t_bb_jenis c ON c.kd_jenis = a.kd_jenis
	WHERE b.kd_perkara ='".KD_PERKARA."'
	";
$q_bb = mysql_query($q_bb_query);

$bb_ada = data_tersedia('t_bb',KD_PERKARA);

if(isset($_GET['b']) && $_GET['b']!="") {
	$b = $_GET['b'];	
	$q_bb_query_detail = "SELECT * FROM t_bb_detail a
					LEFT JOIN t_bb b ON a.kd_bb = b.kd_bb LEFT JOIN t_bb_jenis c ON c.kd_jenis = a.kd_jenis
					WHERE b.kd_perkara ='".KD_PERKARA."' AND a.kd_detail ='".$_GET['b']."'
					";
	$dt = mysql_fetch_array(mysql_query($q_bb_query_detail));

} else {
	$b = "";
	$dt = mysql_fetch_array($q_bb);
}

if($bb_ada) {
	$no_reg_bukti 	= $dt['kd_reg_bb'];
	$kd_bb_detail	= $dt['kd_detail'];
	$tanggal 		= konversi_tanggal('d-m-Y',$dt['tanggal']);
	$jns_bb 		= $dt['kd_jenis'];
	$nama_bb 		= $dt['keterangan'];
	$nama_jenis		= $dt['nm_jenis'];
	$jumlah 		= $dt['jumlah'];
	$kd_bb			= $dt['kd_bb'];
} elseif(!$bb_ada) {
	$no_reg_bukti 	= "";
	$kd_bb_detail	= "";
	$tanggal 		= "";
	$jns_bb 		= "";
	$nama_bb 		= "";
	$nama_jenis		= "";
	$jumlah 		= "";
}
?>
	
<?php
	if($bb_ada) { ?>
	<div class="da-panel-toolbar">
		<div class="btn-toolbar">
			<div class="btn-group">
				<?php 					
					$i = 1;
					$q_bb_tab = mysql_query($q_bb_query);
					while($dt_tab=mysql_fetch_array($q_bb_tab)) { 
						if($i==1) {$d=  true;} else {$d = "";}
				?>
					<a <?php tab_aktif($b,$dt_tab['kd_detail'],PAGE_ID.'&p3=bb&b='.$dt_tab['kd_detail'],$d)?>>Barang Bukti <?php echo $i ?></a>
				<?php 
					$i++; }?>
			</div>
		</div>
	</div>
	<table class="da-table da-detail-view no-border">
		<tbody>
		<tr>
			<th>No. Registrasi</th>
			<td><?php echo $no_reg_bukti;?></td>
		</tr>
		
		<tr>
			<th>Nama Barang</th>
			<td><?php echo $nama_bb;?></td>
		</tr>
		<tr>
			<th>Jenis Barang</th>
			<td><?php echo $nama_jenis;?></td>
		</tr>
		<tr>
			<th>Jumlah Barang</th>
			<td><?php echo $jumlah;?></td>
		</tr>
		<tr>
			<th>Tanggal</th>
			<td><?php echo $tanggal;?></td>
		</tr>
		</tbody>
	</table>
	<div class="da-panel-content with-padding">
		<div class="da-gallery prettyPhoto">
			<strong><span>Foto</span></strong>
			<ul>
				<?php 					
					$q = mysql_query("SELECT * FROM t_bb_file a inner join t_bb b on a.kd_bb=b.kd_bb where a.kd_bb='$kd_bb'");
						while($dt = mysql_fetch_array($q)) {
							
				?>
						<li>
							<a href="<?php echo $dt['path_file']?>" rel="prettyPhoto[pp1]">
								<img src="<?php echo $dt['path_file']?>" alt="">
							</a>
						</li>
						
				<?php }	?>
			</ul>
		</div>
	</div>
<?php } ?>

